package lab02.Test06;
//
/**
 * Created by Administrator on 2017/10/14.
 */
public class Triangle {
    private double a;
    private double b;
    private double c;
    Boolean isTriangle;
    double area;
    double perimeter;

    public Triangle() {

    }

    public void setA(double a) {
        this.a = a;
    }

    public double getA() {
        return a;
    }

    public void setB(double b) {
        this.b = b;
    }

    public double getB() {
        return b;
    }

    public void setC(double c) {
        this.c = c;
    }

    public double getC() {
        return c;
    }


    public void Triangle() {
        if (a + b > c & a + c > b & b + c > a) {
            isTriangle = true;
        } else {
            isTriangle = false;
        }
        System.out.print("一边:" + a + " 一边：" + b + "  一边：" + c);
        if (isTriangle == true) {
            System.out.println("能构成三角形。");
        } else System.out.println("不能构成三角形！！！");
    }

    public void getTriangleArea(double a, double b, double c) {
        if (isTriangle) {
            double helon = (a + b + c) / 2;
            area = Math.sqrt(helon * (helon - a) * (helon - b) * (helon - c));
            System.out.println("三角形面积是：" + area);
        } else System.out.println("由于三边错误，无法计算面积！");
    }

    public void getTrinanglePerimeter(double a, double b, double c) {
        if (isTriangle) {
            perimeter = a + b + c;
            System.out.println("三角形周长是：" + perimeter);
        } else System.out.println("由于三边错误，无法计算周长！");
    }
}
